class SyncWaterFallHook {
  constructor () {
    this.tasks = []
  }

  tap (name, task) {
    this.tasks.push(task)
  }

  call (...args) {
    const [ first, ...other ] = this.tasks
    let fet = first(...args)

    other.reduce((prev, next) => next(prev), fet)
    // this.tasks.forEach(task => task(...args))
  }
}

let hook = new SyncWaterFallHook(['name'])

hook.tap('react', (name) => {
  console.log('react', name)
  return 'react 已完成！'
})

hook.tap('node', (name) => {
  console.log('node', name)
})

hook.call('xyf')
